package com.fuxi.cloud.common.constant;

/**
 * ErrorCode
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-04-19
 */
public enum ErrorCode {
    OK(100, "操作成功"),
    FAIL(101, "操作失败"),
    ALERT(102, "alert"),
    ERROR(5000, "error");

    private int code;
    private String message;

    private ErrorCode() {
    }

    private ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ErrorCode getResultEnum(int code) {
        ErrorCode[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            ErrorCode var4 = var1[var3];
            if (var4.getCode() == code) {
                return var4;
            }
        }

        return ERROR;
    }

    public static ErrorCode getResultEnum(String message) {
        ErrorCode[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            ErrorCode var4 = var1[var3];
            if (var4.getMessage().equals(message)) {
                return var4;
            }
        }

        return ERROR;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }
}
